package summary;

/**
 * @Author: 海琳琦
 * @Date: 2022/3/13 22:43
 * https://leetcode-cn.com/problems/find-bottom-left-tree-value/ 340
 */
public class Title661 {

    /**
     *
     * @param img
     * @return
     */
    public int[][] imageSmoother(int[][] img) {
        //行
        int n = img.length;
        //列
        int m = img[0].length;
        int[][] result = new int[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                int num = 0, sum = 0;
                for (int k = i - 1; k <= i + 1; k++) {
                    for (int l = j - 1; l <= j + 1; l++) {
                        if (k >= 0 && k < n && l >= 0 && l < m) {
                            num++;
                            sum += img[k][l];
                        }
                    }
                }
                sum /= num;
                result[i][j] = sum;
            }
        }
        return result;
    }

    public static void main(String[] args) {

    }

}
